package org.example.short_link.admin.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.example.short_link.admin.common.convention.result.Result;
import org.example.short_link.admin.common.convention.result.Results;
import org.example.short_link.admin.remote.dto.req.RecycleBinRemoveDTO;
import org.example.short_link.admin.remote.dto.req.RecycleBinSaveDTO;
import org.example.short_link.admin.remote.dto.req.RecyclePageReqDTO;
import org.example.short_link.admin.remote.ShortLinkRemoteService;
import org.example.short_link.admin.remote.dto.resp.ShortLinkPageRespDTO;
import org.example.short_link.admin.service.RecycleBinService;
import org.example.short_link.project.dto.req.RecycleBinRecoverDTO;
import org.springframework.web.bind.annotation.*;


@RestController
@RequiredArgsConstructor
public class RecycleBinController {


    private final RecycleBinService recycleBinService;

    // TODO : 后续重构为 SpringCould Field调用
    ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService(){

    };


    /**
     * 短链接移至回收站
     * @param requestParm
     * @return
     */
    @PostMapping("/api/short-link/admin/v1/recycle-bin/save")
    public Result<Void> RecycleBinSave(@RequestBody RecycleBinSaveDTO requestParm){
        shortLinkRemoteService.RecycleBinSave(requestParm);
        return Results.success();
    }

    /**
     * 短链接回收站分页查询
     * @param requestParam
     * @return
     */
    @GetMapping("/api/short-link/admin/v1/recycle-bin/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycle(RecyclePageReqDTO requestParam){
        return recycleBinService.pageRecycle(requestParam);
    }

    /**
     * 短链接回收站恢复功能
     * @param requestParam 短链接回收功能请求参数
     * @return 返回参数
     */
    @PostMapping("/api/short-link/admin/v1/recycle-bin/recover")
    public Result<Void> RecycleBinRecover(@RequestBody RecycleBinRecoverDTO requestParam){
        shortLinkRemoteService.RecycleBinRecover(requestParam);
        return Results.success();
    }

    /**
     * 短链接回收站移除
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/admin/v1/recycle-bin/remove")
    public Result<Void> RecycleBinRemove(@RequestBody RecycleBinRemoveDTO requestParam){
        shortLinkRemoteService.RecycleBinRemove(requestParam);
        return Results.success();
    }


}
